package com.yanqu.road.server.cmd.activity.langyabang;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.LangYaBangProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.langyabang.CrossLangYaBangMgr;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

import java.util.List;

@Cmd(code = CrossProtocol.C_LANG_YA_CROSS_UPDATE_AUTO_SWITCH,desc = "更新自动切换")
public class CrossLangYaUpdateAutoSwitchCmd extends CrossUnionCommand {

    private int activityId;

    private List<Integer> openSwitchList;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        LangYaBangProto.LangYaBangSetAutoSwitchReqMsg reqMsg = LangYaBangProto.LangYaBangSetAutoSwitchReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        openSwitchList = reqMsg.getOpenSwitchTypeList();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        LangYaBangProto.LangYaBangSetAutoSwitchRespMsg.Builder builder = CrossLangYaBangMgr.updateAutoSwitch(activityId, groupId, packet.getPlayerId(), openSwitchList);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(ClientProtocol.U_LANG_YA_BANG_SET_AUTO_SWITCH,builder);
        MessageHelper.sendPacket(serverId,packet.getPlayerId(),pbMsg);

    }

    @Override
    public void sendData() {

    }
}
